package com.model;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Dictionnaire {

	private ArrayList<String> dict;
	
	// constructeur Dictionnaire
	public Dictionnaire (String fichierdict) {
	
		dict= new ArrayList<String>(); 
		String line;
		try {
			InputStream lf =new FileInputStream(fichierdict);
			InputStreamReader lfr= new InputStreamReader(lf);
			BufferedReader br=new BufferedReader(lfr);
			while((line=br.readLine())!= null){
				dict.add(line);
				
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}  catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		
		
	}
	
	// getters 
	
	public ArrayList<String> getDict() {
		return dict;
	}
	// setter
	public void setDict(ArrayList<String> dict) {
		this.dict = dict;
	}
	
	// methode retirer un mot dans le dictionnaire
	
	public String retiremot(){
		int longueur =dict.size();
		int indice=(int)(Math.random()*longueur);
		return dict.get(indice);
		
	}
	
	
/*	Dictionnaire 
 
	public static void main(String[] args){
		Dictionnaire dico= new Dictionnaire("ressources/dico.txt");
		System.out.println(dico.retiremot());
	}*/


}
